Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Nov 20, 2025

First commit: New doc page for decomposed mutables

Todo:

  • discuss the design
  • implementation

r
```
Here, `r` is a fresh reference of type `Ref[String]` that escapes the scope of `withFile`. That's OK only since
`Ref` is classified as `Unscoped`. Since `Unscoped` is a [classifier](./classifiers.md) it means that `Ref` cannot possibly capture `f`, which as a `File` is not classified as `Unscoped`. So returning a `Ref`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a scoped capability capture an unscoped capability?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the Ref need to be fresh to be allowed to be captured by the value returned from op?

For example, suppose we changed the signature of withFile to:

def withFile[T](op: (f: File^, r: Ref[String]^) => T): T =

Could we then call it with an op whose result type captures r?

Also: drop redundant statement in captureSetImpliedByFields
Still missing: Make Mutable an Unscoped
Fix: the APPLY rule had to be changed so that it does not kick in if the
result has Unscoped capabilities. These need to be preserved, we cannot
approximate by the (possibly pure) function type.
@odersky odersky requested a review from a team as a code owner November 21, 2025 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants